package com.fdb.smcts.core.util;

/**
 * @description:全局链路跟踪流水号工具类
 * @date:2019年1月28日 上午11:20:22
 * @author:hengyh
 */
public class TraceUtil {
	public static final String TRACEID = "TRACE_ID";
	// GlblSrlNo 全局流水号
	// InrSrlNo 系统流水号
	// SubtrxNo 子交易序号
	// CnsmrSysID 消费方系统编号
	// PvdrSysID 提供方系统编号
	// SvcId 服务ID
	// CnsmrTxnCd 交易码
	// RetSt 返回状态
	// RetCd 返回代码
	// RetMsg 返回信息
	// INSTID 机构id
	public static final String GLBLSRLNO = "GlblSrlNo";
	public static final String PLATFMID = "PlafmID";
	public static final String PLAFMUSRID = "PlafmUsrID";
	public static final String INRSRLNO = "InrSrlNo";
	public static final String SUBTRXNO = "SubtrxNo";
	public static final String CNSMRSYSID = "CnsmrSysID";
	public static final String PVDRSYSID = "PvdrSysID";
	public static final String SVCID = "SvcId";
	public static final String CNSMRTXNCD = "CnsmrTxnCd";
	public static final String RETST = "RetSt";
	public static final String RETCD = "RetCd";
	public static final String RETMSG = "RetMsg";
	public static final String ROUTINGKEY= "ROUTINGKEY";
	public static final String INSTID= "INSTID";
	public static final String CNLTP= "CnlTp";
	
	private static ThreadLocal<String> traceId = new ThreadLocal<>();
	private static ThreadLocal<String> plafmID = new ThreadLocal<>();
	private static ThreadLocal<String> plafmUsrID = new ThreadLocal<>();
	private static ThreadLocal<String> GlblSrlNo = new ThreadLocal<>();
	private static ThreadLocal<String> InrSrlNo = new ThreadLocal<>();
	private static ThreadLocal<String> SubtrxNo = new ThreadLocal<>();
	private static ThreadLocal<String> CnsmrSysID = new ThreadLocal<>();
	private static ThreadLocal<String> PvdrSysID = new ThreadLocal<>();
	private static ThreadLocal<String> SvcId = new ThreadLocal<>();
	private static ThreadLocal<String> CnsmrTxnCd = new ThreadLocal<>();
	private static ThreadLocal<String> RetSt = new ThreadLocal<>();
	private static ThreadLocal<String> RetCd = new ThreadLocal<>();
	private static ThreadLocal<String> RetMsg = new ThreadLocal<>();
	private static ThreadLocal<String> RoutingKey = new ThreadLocal<>();
	private static ThreadLocal<String> InstId = new ThreadLocal<>();
	private static ThreadLocal<String> CnlTp = new ThreadLocal<>();

	public static void clear() {
		traceId.remove();
		GlblSrlNo.remove();
		InrSrlNo.remove();
		SubtrxNo.remove();
		CnsmrSysID.remove();
		PvdrSysID.remove();
		SvcId.remove();
		CnsmrTxnCd.remove();
		RetSt.remove();
		RetCd.remove();
		RetMsg.remove();
		RoutingKey.remove();
		plafmID.remove();
		plafmUsrID.remove();
		CnlTp.remove();
		InstId.remove();
	}
	
	public static String getPlafmUsrID() {
		return plafmUsrID.get();
	}

	public static void setPlafmUsrID(String str) {
		plafmUsrID.set(str);
	}
	
	public static String getPlafmID() {
		return plafmID.get();
	}

	public static void setPlafmID(String str) {
		plafmID.set(str);
	}
	
	public static void setRoutingKey(String curRoutingKey) {
		RoutingKey.set(curRoutingKey);
	}
	
	public static String getRoutingKey() {
		return RoutingKey.get();
	}
	
	public static void setTraceId(String curTraceId) {
		traceId.set(curTraceId);
	}

	public static void setGlblSrlNo(String curGlblSrlNo) {
		GlblSrlNo.set(curGlblSrlNo);
	}

	public static void setInrSrlNo(String curInrSrlNo) {
		InrSrlNo.set(curInrSrlNo);
	}

	public static void setSubtrxNo(String curSubtrxNo) {
		SubtrxNo.set(curSubtrxNo);
	}

	public static void setCnsmrSysID(String curCnsmrSysID) {
		CnsmrSysID.set(curCnsmrSysID);
	}

	public static void setPvdrSysID(String curPvdrSysID) {
		PvdrSysID.set(curPvdrSysID);
	}

	public static void setSvcId(String curSvcId) {
		SvcId.set(curSvcId);
	}

	public static void setCnsmrTxnCd(String curCnsmrTxnCd) {
		CnsmrTxnCd.set(curCnsmrTxnCd);
	}

	public static void setRetSt(String curRetSt) {
		RetSt.set(curRetSt);
	}

	public static void setRetCd(String curRetCd) {
		RetCd.set(curRetCd);
	}

	public static void setRetMsg(String curRetMsg) {
		RetMsg.set(curRetMsg);
	}
	
	public static void setInstId(String instId) {
		InstId.set(instId);
	}

	public static void setCnlTp(String cnlTp) {
		CnlTp.set(cnlTp);
	}
	
	public static String getTraceId() {
		return traceId.get();
	}

	public static String getGlblSrlNo() {
		return GlblSrlNo.get();
	}

	public static String getInrSrlNo() {
		return InrSrlNo.get();
	}

	public static String getSubtrxNo() {
		return SubtrxNo.get();
	}

	public static String getCnsmrSysID() {
		return CnsmrSysID.get();
	}

	public static String getPvdrSysID() {
		return PvdrSysID.get();
	}

	public static String getSvcId() {
		return SvcId.get();
	}

	public static String getCnsmrTxnCd() {
		return CnsmrTxnCd.get();
	}

	public static String getRetSt() {
		return RetSt.get();
	}

	public static String getRetCd() {
		return RetCd.get();
	}

	public static String getRetMsg() {
		return RetMsg.get();
	}

	public static String getInstId() {
		return InstId.get();
	}

		public static String getCnlTp() {
		return CnlTp.get();
	}
}
